import React from 'react'
import {HashRouter, Route, Switch, Redirect} from 'react-router-dom'
import App from './App'
import Login from './pages/login'
import Home from './pages/home'
import Admin from './admin'
import Buttons from './pages/admin/ui/buttons'
import noMatch from './pages/nomatch'
import Modals from './pages/admin/ui/modals'
import Loadings from './pages/admin/ui/loadings'
import Notice from './pages/admin/ui/notice'
import Messages from './pages/admin/ui/messages'
import Tabs from './pages/admin/ui/tabs'
import Gallery from './pages/admin/ui/gallery'
import Carousels from './pages/admin/ui/carousel'
import FormLogin from './pages/admin/form/login'
import FormRegister from './pages/admin/form/register'
import BasicTable from './pages/admin/table/basicTable'
import City from './pages/admin/city'
import Order from './pages/admin/order'
import User from './pages/admin/user'
import Permission from './pages/admin/permission'
import Common from './common'

export default class JustRouter extends React.Component {

    render() {
        return (
            <HashRouter>
                <App>
                    <Switch>
                        <Route path={'/login.js'} component={Login}/>
                        {/*<Route path={'/admin'} component={Admin} />*/}
                        <Route path={'/'} render={() =>
                            <Admin>
                                <Switch>
                                    <Route path={'/home'} component={Home}/>
                                    <Route path={'/admin/ui/buttons'} component={Buttons}/>
                                    <Route path={'/admin/ui/modals'} component={Modals}/>
                                    <Route path={'/admin/ui/loadings'} component={Loadings}/>
                                    <Route path={'/admin/ui/notification'} component={Notice}/>
                                    <Route path={'/admin/ui/messages'} component={Messages}/>
                                    <Route path={'/admin/ui/tabs'} component={Tabs}/>
                                    <Route path={'/admin/ui/gallery'} component={Gallery}/>
                                    <Route path={'/admin/ui/carousel'} component={Carousels}/>
                                    <Route path={'/admin/form/login'} component={FormLogin}/>
                                    <Route path={'/admin/form/register'} component={FormRegister}/>
                                    <Route path={'/admin/table/basic'} component={BasicTable}/>
                                    <Route path={'/admin/city'} component={City}/>
                                    <Route path={'/admin/order'} component={Order}/>
                                    <Route path={'/admin/user'} component={User}/>
                                    <Route path={'/admin/permission'} component={Permission}/>
                                    <Redirect to='/home'/>
                                    {/*<Route component={noMatch}></Route>*/}
                                </Switch>
                            </Admin>
                        }/>
                        <Route path={'/common'} render={() =>
                            <Common>
                                <Switch>
                                    <Route path={'/common/order/detial/:orderId'} component={Buttons}/>
                                    <Route component={noMatch}></Route>
                                </Switch>
                            </Common>
                        }/>
                        <Route component={noMatch}></Route>
                    </Switch>
                </App>
            </HashRouter>
        );
    }
}
